{template 'common/header'}
<link type="text/css" rel="stylesheet" href="./resource/style/daterangepicker.css" />
<script type="text/javascript" src="./resource/script/daterangepicker.js"></script>
<script type="text/javascript">
$(function() {
	$('#date-range').daterangepicker({
		format: 'YYYY-MM-DD',
		startDate: $(':hidden[name=start]').val(),
		endDate: $(':hidden[name=end]').val(),
		locale: {
			applyLabel: '确定',
			cancelLabel: '取消',
			fromLabel: '从',
			toLabel: '至',
			weekLabel: '周',
			customRangeLabel: '日期范围',
			daysOfWeek: moment()._lang._weekdaysMin.slice(),
			monthNames: moment()._lang._monthsShort.slice(),
			firstDay: 0
		}
	}, function(start, end){
		$('#date-range .date-title').html(start.format('YYYY-MM-DD') + ' 至 ' + end.format('YYYY-MM-DD'));
		$(':hidden[name=start]').val(start.format('YYYY-MM-DD'));
		$(':hidden[name=end]').val(end.format('YYYY-MM-DD'));
	});
});
function range(days) {
	var start = moment().add('days', 0 - days).format('YYYY-MM-DD');
	var end = moment().format('YYYY-MM-DD');
	$('#date-range .date-title').html(start + ' 至 ' + end);
	$(':hidden[name=start]').val(start);
	$(':hidden[name=end]').val(end);
	$('form[method=get]')[0].submit();
}
</script>
	<ul class="nav nav-tabs">
		<li><a href="{php echo create_url('site/module/post', array('name' => 'qrcode'));}">生成二维码</a></li>
		<li><a href="{php echo create_url('site/module/list', array('name' => 'qrcode'));}">管理二维码</a></li>
		<li class="active"><a href="{php echo create_url('site/module/display', array('name' => 'qrcode'));}">扫描统计</a></li>
	</ul>
	<div class="main">
		<div class="stat">
			<div class="stat-div">
				<div class="navbar navbar-static-top">
					<div class="navbar-inner">
						<span class="brand">二维码扫描统计</span>
						<div class="pull-left"></div>
					</div>
				</div>
				<div class="sub-item">
					<form action="site.php" method="get">
					<div class="pull-right">
						<input class="btn btn-primary" type="submit" value="搜索">
					</div>
					<div class="pull-left">
						<input name="act" type="hidden" value="module" />
						<input name="do" type="hidden" value="display" />
						<input name="name" type="hidden" value="qrcode" />
						<input type="text" class="span2 kw" name="keyword" value="{$_GPC['keyword']}" placeholder="请输入关键字">
						<input name="start" type="hidden" value="{php echo date('Y-m-d', $starttime)}" />
						<input name="end" type="hidden" value="{php echo date('Y-m-d', $endtime)}" />
						<button class="btn date" id="date-range" type="button"><span class="date-title">{php echo date('Y-m-d', $starttime)} 至 {php echo date('Y-m-d', $endtime)}</span> <i class="icon-caret-down"></i></button>
						<span class="date-section"><a href="javascript:;" onclick="range(7);">7天</a><a href="javascript:;" onclick="range(14);">14天</a><a href="javascript:;" onclick="range(30);">30天</a></span>
					</div>
					</form>
				</div>
				<div class="sub-item" id="table-list">
					<h4 class="sub-title">详细数据&nbsp;&nbsp;&nbsp;&nbsp;<small style="color:red;">扫描人数：{php echo count($list);}</small></h4>
					<div class="sub-content">
						<table class="table table-hover">
							<thead class="navbar-inner">
								<tr>
									<th style="width:200px;">粉丝<i></i></th>
									<th style="">场景名称<i></i></th>
									<th style="width:100px;">场景ID<i></i></th>
									<th style="width:110px;">关注扫描<i></i></th>
									<th style="width:150px;">扫描时间<i></i></th>
									<th style="width:110px;">操作</th>
								</tr>
							</thead>
							<tbody>
								{loop $list $row}
								<tr>
									<td style="text-align: center;"><a href="#" title="{$row['openid']}">{php echo cutstr($row['openid'], 15)}</a></td>
									<td style="text-align: center;">{$row['name']}</td>
									<td style="text-align: center;">{$row['qrcid']}</td>
									<td style="text-align: center;">{$row['type']}</td>
									<td style="font-size:12px; color:#666;text-align: center;">
									{php echo date('Y-m-d <br /> h:i:s', $row[createtime]);}
									</td>
									<td style="text-align: center;">
									<a href="{php echo create_url('site/module/delsata', array('name' => 'qrcode','id'=>$row['id']));}"  onclick="javascript:return confirm('您确定要删除吗？')">删除</a>
									</td>
								</tr>
								{/loop}
							</tbody>
						</table>
						{$pager}
					</div>
				</div>
			</div>
		</div>
	</div>
<script type="text/javascript">
$(function() {
	//详细数据相关操作
	var tdIndex;
	$("#table-list thead").delegate("th", "mouseover", function(){
		if($(this).find("i").hasClass("")) {
			$("#table-list thead th").each(function() {
				if($(this).find("i").hasClass("icon-sort")) $(this).find("i").attr("class", "");
			});
			$("#table-list thead th").eq($(this).index()).find("i").addClass("icon-sort");
		}
	});
	$("#table-list thead th").click(function() {
		if($(this).find("i").length>0) {
			var a = $(this).find("i");
			if(a.hasClass("icon-sort") || a.hasClass("icon-caret-up")) { //递减排序
				/*
					数据处理代码位置
				*/
				$("#table-list thead th i").attr("class", "");
				a.addClass("icon-caret-down");
			} else if(a.hasClass("icon-caret-down")) { //递增排序
				/*
					数据处理代码位置
				*/
				$("#table-list thead th i").attr("class", "");
				a.addClass("icon-caret-up");
			}
			$("#table-list thead th,#table-list tbody:eq(0) td").removeClass("row-hover");
			$(this).addClass("row-hover");
			tdIndex = $(this).index();
			$("#table-list tbody:eq(0) tr").each(function() {
				$(this).find("td").eq(tdIndex).addClass("row-hover");
			});
		}
	});
});
</script>
{template 'common/footer'}